<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>Admin - University of Technology Library HCM City</title>
	<link rel="stylesheet" type='text/css' href='style.css' />
	<%= stylesheet_link_tag    "admin/application", :media => "all" %>
	<%= javascript_include_tag "jquery-1.7.2" %>
  	<%= javascript_include_tag "admin/application" %>
  	<%= csrf_meta_tags %>
</head>

<body>
<div id='wrapper'>
	<div id='header'>
    	<div class='topbar'>
        	<div class='user-area'>
        		<% if(session[:admin_user_id]) %>
			      Welcome:&nbsp;
			      <span class='Welcome: '><%= link_to User.find(session[:admin_user_id]).username, :controller => 'admin/user', :action => 'setting' %> </span> &nbsp; | &nbsp;
			      <%= link_to "Logout", :controller => 'admin/user', :action => 'logout' %>
			    <% else %>
			      <%= link_to "Login", :controller => 'admin/user', :action => 'login' %>
			    <% end %>
            </div>
        </div>
        <div class='banner'>
        	<div class='logo'><%= image_tag 'logo.png' %></div>
        	<h1>Admin - University of Technology Library HCM City</h1>
        </div>
        
        <% if session[:admin_user_id] %>
        <div class='topnav'>
        	<ul>
        		<li>
        			<%= link_to 'Main', :controller => 'admin/index', :action => 'index' %>
        		</li>
            	<li>
                	<a>Readers</a>
                    <ul>
                    	<% @ctrl = 'admin/user' %>
                    	<% @list_items = VtLibManager::Application::ADMIN_MENU[@ctrl] %>
		        		<% for @item in @list_items do %>
			            	<li><%= link_to @item['text'], :controller => @ctrl, :action => @item['action'] %></li>
		            	<% end %>
                    </ul>
                </li>
            	<li>
                	<a>Books</a>
                    <ul>
                    	<% @ctrl = 'admin/book' %>
                    	<% @list_items = VtLibManager::Application::ADMIN_MENU[@ctrl] %>
		        		<% for @item in @list_items do %>
			            	<li><%= link_to @item['text'], :controller => @ctrl, :action => @item['action'] %></li>
		            	<% end %>
                    </ul>
                </li>
                <li>
                	<a>Book categories</a>
                    <ul>
                    	<% @ctrl = 'admin/book_cate' %>
                    	<% @list_items = VtLibManager::Application::ADMIN_MENU[@ctrl] %>
		        		<% for @item in @list_items do %>
			            	<li><%= link_to @item['text'], :controller => @ctrl, :action => @item['action'] %></li>
		            	<% end %>
                    </ul>
                </li>
                <li>
                	<a>Faculties</a>
                    <ul>
                    	<% @ctrl = 'admin/faculty' %>
                    	<% @list_items = VtLibManager::Application::ADMIN_MENU[@ctrl] %>
		        		<% for @item in @list_items do %>
			            	<li><%= link_to @item['text'], :controller => @ctrl, :action => @item['action'] %></li>
		            	<% end %>
                    </ul>
                </li>
                <li>
                	<a>Borrowing rules</a>
                    <ul>
                    	<% @ctrl = 'admin/borrow_rule' %>
                    	<% @list_items = VtLibManager::Application::ADMIN_MENU[@ctrl] %>
		        		<% for @item in @list_items do %>
			            	<li><%= link_to @item['text'], :controller => @ctrl, :action => @item['action'] %></li>
		            	<% end %>
                    </ul>
                </li>
                <li>
                	<a>Borrow / Return book</a>
                    <ul>
                    	<% @ctrl = 'admin/book_borrow' %>
                    	<% @list_items = VtLibManager::Application::ADMIN_MENU[@ctrl] %>
		        		<% for @item in @list_items do %>
			            	<li><%= link_to @item['text'], :controller => @ctrl, :action => @item['action'] %></li>
		            	<% end %>
                    </ul>
                </li>
                <li>
                	<%= link_to 'Reserved books', :controller => 'admin/book_reserve', :action => 'index' %>
                </li>
                <li>
                	<%= link_to 'Punishment', :controller => 'admin/punishment', :action => 'index' %>
                </li>
            </ul>
        </div><!-- End #topnav -->
        <% end %>
    </div><!-- End #header -->
    <div class='clear'></div>
    <div id='main'>
    	<% if params[:controller] != 'admin/index' and session[:admin_user_id] %>
    	<div id='sidebar'>
    		<h1>Sub Menu</h1>
        	<ul>
        		<% @ctrl = params[:controller] %>
        		<% @list_items = VtLibManager::Application::ADMIN_MENU[@ctrl] %>
        		<% for @item in @list_items do %>
	            	<li><%= link_to @item['text'], :controller => @ctrl, :action => @item['action'] %></li>
            	<% end %>
            	<% if params[:action] == 'view' %>
            		<li><%= link_to 'Edit item', :controller => params[:controller], :action => 'edit', :id => params[:id] %></li>
            		<li><%= link_to 'Delete item', {:controller => params[:controller], :action => 'Delete', :id => params[:id]}, :method => "delete", :data => {:confirm => "Are you sure?"} %></li>
            	<% end %>
            </ul>
        </div><!-- End #sidebar -->
        <% end %>
        <div id='content'>
        	<%= yield %>
        </div><!-- End #content -->
    </div><!-- End #main -->
    <div class='clear'></div>
    <div id='footer'>
    	<center><h3>Copyright &copy; 2012 - 2013</h3></center>
    </div><!-- End #footer -->
</div><!-- End #wrapper -->
</body>
</html>
